<%@ page isELIgnored="false" language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<c:set var="_path" value="${pageContext.request.contextPath}"></c:set>
<form id="cardOpForm" style="margin:10;text-align: center;">
	<table width="100%">
		<tr>
			<td>操作员：</td>
			<td>
				<input name="operator" style="width: 150"/>
			</td>
			<td>汇总方式：</td>
			<td>
				<input id="status1" name="status" type="radio" value="1"/>年
				<input id="status2" name="status" type="radio" value="2"/>月
				<input id="status3" name="status" type="radio" value="3"/>日
			</td>			
			<td align="center">
				<a href="javascript:void(0);" onclick="clearAbaForm()" class="easyui-linkbutton" iconCls="icon-search">清空</a>
			</td>
		</tr>
		<tr>
			<td>开始日期：</td>
			<td>
				<input class="easyui-datebox" id="startDate" name="startDate" style="width: 150"/>
			</td>
			<td>截止日期：</td>
			<td>
				<input class="easyui-datebox" id="endDate" name="endDate" style="width: 150"/>
			</td>
			<td align="center"><a href="javascript:void(0);" onClick="doSearch()" class="easyui-linkbutton" iconCls="icon-search">查询</a></td>
		</tr>
	</table>
</form>
<div id="cardOpTable"></div>
<script>
jQuery(function($){
	$('#cardOpTable').datagrid({
		title:'一卡通操作统计汇总',//标题
		method:'post',
		iconCls:'icon-edit',//图标
		singleSelect:true,//多选
		height:428,
	
		striped: true,//奇偶行颜色不同
		collapsible:false,//可折叠
		remoteSort: true, //服务器端排序
		queryParams:{}, //查询条件
		pagination:true, //显示分页
		rownumbers:true, //显示行号
		showFooter:true,
		columns:[[
			{field:'date',title:'日期',width:80,sortable:true},
			{field:'operator',title:'操作员',width:50},
			{field:'createcardnum',title:'开卡数量',width:80},
			{field:'createcardmoney',title:'开卡金额',width:80},
			{field:'lossedcardnum',title:'挂失数量',width:80},
			{field:'unlossedcardnum',title:'解挂数量',width:80},
			{field:'deletecardnum',title:'解卡数量',width:80},
			{field:'deletecardmoney',title:'解卡金额',width:80},	
			{field:'changecardnum',title:'换卡数量',width:80},
			{field:'changecardmoney',title:'换卡金额',width:80},	
			{field:'rechargenum',title:'充值数量',width:80},
			{field:'rechargemoney',title:'充值金额',width:80},	
			{field:'reversenum',title:'冲账数量',width:80},
			{field:'reversemoney',title:'冲账金额',width:80}
		]],
		toolbar:[{
			text:'导出PDF',
			iconCls:'icon-print',
			handler:function(){
				$('#cardOpForm').attr('method','post');
				$('#cardOpForm').attr('action','${_path}/aba/exportCardOpForPdf');
				$('#cardOpForm').submit();
			}
		},'-',{
			text:'导出EXCEL',
			iconCls:'icon-print',
			handler:function(){
				$('#cardOpForm').attr('method','post');
				$('#cardOpForm').attr('action','${_path}/aba/exportCardOpForExcel');
				$('#cardOpForm').submit();
			}
		}],
		onLoadSuccess:function(){
			$('#cardOpTable').datagrid('clearSelections');//一定要加上这一句，要不然datagrid会记住之前的选择状态，删除时会出问题
		}
	});
});
//表格查询
function doSearch(){
	var val=$('input:radio[name="status"]:checked').val();
	if(val==undefined)
	{
		$.messager.alert('提示',"请选择汇总方式",'info');
		return;
	}
	var v = $('#startDate').datebox('getValue');
	var v1 = $('#endDate').datebox('getValue'); 
	if(v!="" || v1!="")
	{
		if(v=="")
		{
			$.messager.alert('提示',"请选择开始日期",'info');
			return;
		}
		if(v1=="")
		{
			$.messager.alert('提示',"请选择截止日期",'info');
			return;
		}
	}

	var params = $('#cardOpTable').datagrid('options').queryParams;//先取得 datagrid的查询参数
	var fields =$('#cardOpForm').serializeArray();//自动序列化表单元素为JSON对象
	$.each( fields, function(i, field){
		params[field.name] = field.value;//设置查询参数
	}); 
	
	$('#cardOpTable').datagrid({url:'aba/queryCardOpList'});
	$('#cardOpTable').datagrid('reload');
}
//清空查询条件
function clearAbaForm(){
	$('#cardOpForm').form('clear');
	doSearch();
}
</script>